<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>

<html>
<head>
	<meta charset="UTF-8">
    <title>添加机器人</title>
    <%@ include file="head.jsp" %>
</head>
<body>
<div class="layui-col-md12" style="height: 450px;">

        <div  style="width: 70%; height: 400px; margin: 0 auto;
            position: relative; top: 50%; transform: translateY(-50%);">

            <form class="layui-form">
               
			    <div class="layui-form-item">
			        <label class="layui-form-label">机器人名</label>
			        <div class="layui-input-block">
			            <input id="car_name" type="text" name="car_name" required  lay-verify="required" placeholder="请机器人名字" autocomplete="off" class="layui-input">
			        </div>
			    </div>
			    <div class="layui-form-item">
			        <label class="layui-form-label">起点横坐标</label>
			        <div class="layui-input-block">
			            <input id="map_x" type="text" name="map_x" required  lay-verify="number" placeholder="请输入数字" autocomplete="off" class="layui-input">
			        </div>
			    </div>
			             
			    <div id="deg_z" class="layui-form-item">
			        <label class="layui-form-label">起点纵坐标</label>
			        <div class="layui-input-block">
			            <input id="map_y" type="text" name="map_y" required  lay-verify="number" placeholder="请输入数字" autocomplete="off" class="layui-input">
			        </div>
			    </div>
				
			    <div class="layui-form-item">
			  			<label class="layui-form-label">机器人出厂日期</label>
			                 <div class="layui-input-block">
				      	<input id="car_bir" class="layui-input" name="car_bir" placeholder="请选择日期" />
			                 </div>
			  	</div>
			    <div class="layui-form-item">
			        <div class="layui-input-block">
			            <button class="layui-btn layui-btn-sm" lay-submit lay-filter="formDemo">确定</button>
			            <button type="reset" class="layui-btn layui-btn-sm layui-btn-primary">重置</button>
			        </div>
			    </div>
            </form>
        </div>
    </div>



<script>
    //Demo
    layui.use(['form','laydate'], function(){
    	 var form = layui.form;
         var $ = layui.$;
         var element = layui.element;
         var layer = layui.layer;

         var laydate = layui.laydate;
         
         
         
         /* 显示当前时间函数  */
         function show(){
         	   var mydate = new Date();
         	   
         	   var str = "" + mydate.getFullYear() + "-";
         	   str += (mydate.getMonth()+1) + "-";
         	   str += mydate.getDate() ;
         	   return str;
         }
         
         /* 日期选择的初始化 */
        laydate.render({
 		    elem: '#car_bir'
 		    ,type:'date'
 		    ,max: show()
 		    ,btns: ['clear','now', 'confirm']
 		});
         
        form.on('submit(formDemo)', function(data,index){
            var data1 = JSON.stringify(data.field);
			
            $.post("addCar","data="+data1,function(msg){
				//alert(msg);
				if(msg == "success"){
					layer.msg("添加机器人成功！");
					//location.href="car_msg" ;
					parent.location.reload();
				}
            });
			
            layer.close(index);
            var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
            parent.layer.close(index);

            
            return false;
        });
    });
</script>



</body>
</html>